import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

import path from 'path';
import { svgBuilder } from './src/plugins/svgBuilder';

const srcPath = path.resolve(__dirname, 'src')

// https://vitejs.dev/config/
export default defineConfig({

  css: {
    preprocessorOptions: {
      scss: {
        charset: false
      }
    },
    postcss: {
      plugins: [
        {
          postcssPlugin: 'internal:charset-removal',
          AtRule: {
            charset: (atRule) => {
              if (atRule.name === 'charset') {
                atRule.remove();
              }
            }
          }
        }
      ],
    },
  },
  plugins: [vue(), svgBuilder('./src/assets/icons/svg/')],
  server: {
    port: 5051,
    strictPort: true,
  },
  base: "./",//编译后config目录位置不对修改
  resolve: {
    alias: [
      { find: '@', replacement: srcPath },
    ]
  }
})
